"""
    夸类调用
        两个类互相调用
"""

# 以面向对象的思维思想描述场景：老张开车去东北
# 写法1：直接创建对象
# 语义：老张每次开一辆新车去东北
class Person:
    def __init__(self, name=""):
        self.name = name

    def go_to(self,position):
        print(self.name,"去",position)
        car = Car()
        car.run()

class Car:
    def run(self):
        print("汽车嘟嘟嘟嘟嘟嘟嘟...在行驶")
# 老张去东北
lz = Person("老张")
lz.go_to("东北")


# 写法2：在构造函数中创建对象
# 语义：老张开自己的车去东北
class Person:
    def __init__(self, name=""):
        self.name = name
        self.car = Car()

    def go_to(self,position):
        print(self.name,"去",position)
        self.car.run()

class Car:
    def run(self):
        print("汽车嘟嘟嘟嘟嘟嘟嘟...在行驶")
# 老张去东北
lz = Person("老张")
lz.go_to("东北")

# 写法3：在构造函数中创建对象
# 语义：老张开自己的车去东北
class Person:
    def __init__(self, name=""):
        self.name = name

    def go_to(self,position,car):
        print(self.name,"去",position)
        car.run()

class Car:
    def run(self):
        print("汽车嘟嘟嘟嘟嘟嘟嘟...在行驶")

lz = Person("老张")
car = Car()
lz.go_to("东北",car)